<template>
    <view>
        <!-- logs.wxml -->
        <navigation-bar title="查看启动日志" :back="true" color="black" background="#FFF"></navigation-bar>
        <scroll-view class="scrollarea" scroll-y type="list">
            <block v-for="(log, index) in logs" :key="index">
                <view class="log-item">{{ index + 1 }}. {{ log.date }}</view>
            </block>
        </scroll-view>
    </view>
</template>

<script>
import navigationBar from '@/components/navigation-bar/navigation-bar';
// logs.js
const util = require('../../utils/util.js');
export default {
    components: {
        navigationBar
    },
    data() {
        return {
            logs: [],

            log: {
                date: ''
            }
        };
    },
    mounted() {
        // 处理小程序 attached 生命周期
        this.attached();
    },
    methods: {
        attached() {
            this.setData({
                logs: (uni.getStorageSync('logs') || []).map((log) => {
                    return {
                        date: util.formatTime(new Date(log)),
                        timeStamp: log
                    };
                })
            });
        }
    },
    created: function () {}
};
</script>
<style>
page {
    height: 100vh;
    display: flex;
    flex-direction: column;
}
.scrollarea {
    flex: 1;
    overflow-y: hidden;
}
.log-item {
    margin-top: 20rpx;
    text-align: center;
}
.log-item:last-child {
    padding-bottom: env(safe-area-inset-bottom);
}
</style>
